package com.zhuss.controller.core;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.core.DetailIconBo;
import com.zhuss.bean.bo.core.user.CidBo;
import com.zhuss.bean.unit.GetuiItem;
import com.zhuss.car.processor.cache.CarCache;
import com.zhuss.car.processor.cache.DriverCache;
import com.zhuss.common.AbstractBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.SelectVo;
import com.zhuss.controller.GetuiUtils;
import com.zhuss.controller.common.Icon;
import com.zhuss.core.annotation.Anon;
import com.zhuss.core.processor.cache.CompanyCache;
import com.zhuss.enums.CanSellType;
import com.zhuss.enums.EnumUtil;
import com.zhuss.enums.ImportType;
import com.zhuss.enums.InfoVisible;
import com.zhuss.enums.IsEnum;
import com.zhuss.enums.NoticeType;
import com.zhuss.enums.OperationStatus;
import com.zhuss.enums.ProductType;
import com.zhuss.enums.RequestMethod;
import com.zhuss.enums.ResourceType;
import com.zhuss.enums.RideType;
import com.zhuss.enums.RoleType;
import com.zhuss.enums.Sex;
import com.zhuss.enums.SiteType;
import com.zhuss.enums.StartStopEnum;
import com.zhuss.enums.StrategyType;
import com.zhuss.enums.SystemCHEnum;
import com.zhuss.enums.SystemEnum;
import com.zhuss.enums.TakeType;
import com.zhuss.enums.TravelPurpose;
import com.zhuss.enums.公司类型;
import com.zhuss.enums.订单状态显示2;
import com.zhuss.enums.车辆类型;
import com.zhuss.exception.DzcxException;
import com.zhuss.product.processor.cache.LineCache;
import com.zhuss.product.processor.cache.LineStrategyCache;
import com.zhuss.product.processor.cache.SiteCache;
import com.zhuss.product.processor.cache.SiteStrategyCache;
import com.zhuss.product.processor.cache.StrategySiteCache;
import com.zhuss.product.processor.cache.StrategyTrainCache;
import com.zhuss.product.processor.cache.TrainCache;
import com.zhuss.util.AliSmsService;
import com.zhuss.util.DateUtil;


/**
 * 下拉框 controller
 * @Author zhushanshuo
   @Date 2019-11-27 19:58
 *
 */
@Anon
@RestController
@RequestMapping("/select")
public class SelectController extends BaseController {
	
	@Autowired
	private AliSmsService aliSmsService;

	@Autowired
	private CarCache carCache;

	@Autowired
	private DriverCache driverCache;

	@Autowired
	private CompanyCache companyCache;

	@Autowired
	private SiteCache siteCache;

	@Autowired
	private LineCache lineCache;

	@Autowired
	private SiteStrategyCache siteStrategyCache;

	@Autowired
	private LineStrategyCache lineStrategyCache;

	@Autowired
	private StrategySiteCache strategySiteCache;

	@Autowired
	private StrategyTrainCache strategyTrainCache;

	@Autowired
	private TrainCache trainCache;
	
	
	@ResponseBody
	@RequestMapping("/testPush")
	public void testPush(@RequestBody CidBo bo) throws DzcxException {
		
//		List<Date> dateList = new ArrayList<>();
//		dateList.add(new Date());
//		OrderTemplateParam orderTemplateParam = new OrderTemplateParam();
//		orderTemplateParam.setDateList(dateList);
//		orderTemplateParam.setNum(1);
//		orderTemplateParam.setOnSiteName("站1");
//		orderTemplateParam.setOffSiteName("站2");
//		orderTemplateParam.setPersonNum(1);
//		orderTemplateParam.setTotalPrice(100 * 1 * 1 / 100 + "");
//		orderTemplateParam.setCreator("zss");
//		aliSmsService.sendOrderMsg("18317100362", JsonUtil.toJson(orderTemplateParam));
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				try {
					GetuiUtils.pushMessageToSingle(GetuiItem.test, bo.getCid(), GetuiItem.test, null);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}).start();
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
				try {
					GetuiUtils.pushTransMessageToSingle(GetuiItem.test, bo.getCid(), GetuiItem.test, 1);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}).start();
	}

	/**
	 * 获取物业管理部门类别
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/thirdDeptType")
	public Object thirdDeptType() throws DzcxException {
		return EnumUtil.listSelect(公司类型.class);
	}


	/**
	 * 信息发布可见性下拉框
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/infoVisibleList")
	public Object infoVisibleList() throws DzcxException {
		return EnumUtil.listSelect(InfoVisible.class);
	}

	/**
	 * 是否下拉框
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
    @RequestMapping("/isList")
    public Object isList() throws DzcxException {
		// return Integer.MIN_VALUE;

		/*Object list = carCache.getList();
		Object obj = carCache.get(5l);
		// carCache.clear(100l);
		System.out.println(list);
		System.out.println(obj);



		obj = driverCache.get(3l);
		list = driverCache.getList();



		obj = companyCache.get(6l);
		list = companyCache.getList();



		obj = siteCache.get(4601l);
		list = siteCache.getList();



		Object list2 = siteStrategyCache.getStart(4860l);
		list2 = siteStrategyCache.getEnd(4862l);
		list2 = siteStrategyCache.get(4860l, 4860l, Arrays.asList(10));
		list2 = siteStrategyCache.getType(10);



		obj = lineStrategyCache.get(17l);
		list2 = lineStrategyCache.getList();



		list2 = strategySiteCache.get(17l);



		list2 = strategyTrainCache.get(17l);



		obj = trainCache.get(45l);
		list2 = trainCache.getList();




		carCache.clear(100l);
		carCache.clear(5l);


		driverCache.clear(100l);
		driverCache.clear(3l);


		companyCache.clear(6l);

		siteCache.clear(4602l);
		siteCache.clear(4601l);


		siteStrategyCache.clearStart(4860l);
		siteStrategyCache.clear(4860l);


		lineStrategyCache.clear(17l);

		strategySiteCache.clear(17l);


		strategyTrainCache.clear(17l);

		trainCache.clear(46l);
		trainCache.clear(45l);

		System.out.println(list2);*/
		//siteStrategyCache.clear(1l);
		//siteStrategyCache.clearStart(1l);
		//siteStrategyCache.clearEnd(1l);
		//siteStrategyCache.clearType(1);
		//GetuiUtils.pushMessageToSingle("0d81a487c73b6651df24fcc1783796dc", "通知", "zhaoxiaoyu1", "123");
		//GetuiUtils.pushtoAPP("通知", "zhaoxiaoyu2", "12");
		//GetuiUtils.pushTransMessageToSingle("ed0706a80759062cdbcd23adacfd3e93", "{title:\"123\",content:\"456\",payload:\"789数据\"}");
		//GetuiUtils.pushTransMessageToSingle("0d81a487c73b6651df24fcc1783796dc", "{title:\"123\",content:\"456\",payload:\"789数据\"}");
		//GetuiUtils.pushTransMessageToSingle(GetuiItem.收到报修勘察提醒, "13f83cc6419f66dfe3c152efae1a5524b91750f608b1f81ab1b70ac7ec1134eb", "", 10);
		return EnumUtil.listSelect(IsEnum.class);
    }

	/**
	 * 系统
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
    @RequestMapping("/systemList")
    public Object systemList() throws DzcxException {
		return EnumUtil.listSelect(SystemEnum.class);
    }

	/**
	 * 资源类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
    @RequestMapping("/resourceTypeList")
    public Object resourceTypeList() throws DzcxException {
		return EnumUtil.listSelect(ResourceType.class);
    }

	/**
	 * 请求方法
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/requestMethodList")
	public Object requestMethodList() throws DzcxException {
		return EnumUtil.listSelect(RequestMethod.class);
	}

	/**
	 * 角色类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/roleTypeList")
	public Object roleTypeList() throws DzcxException {
		return EnumUtil.listSelect(RoleType.class);
	}

	/**
	 * 启用停用
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/startStopList")
	public Object startStopList() throws DzcxException {
		return EnumUtil.listSelect(StartStopEnum.class);
	}

	/**
	 * 性别
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/sexList")
	public Object sexList() throws DzcxException {
		return EnumUtil.listSelect(Sex.class);
	}

	/**
	 * 公司类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/companyTypeList")
	public Object companyTypeList() throws DzcxException {
		return EnumUtil.listSelect(SystemCHEnum.class);
	}

	/**
	 * 导入类型下拉框
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/importTypeList")
	public Object importTypeList(@RequestBody AbstractBo bo) throws DzcxException {
		return EnumUtil.listSelect(ImportType.class);
	}

	/**
	 * 未来周下拉框
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/futureWeekList")
	public Object futureWeekList(@RequestBody AbstractBo bo) throws DzcxException {
		List<SelectVo> weekList = DateUtil.toWeekList(4l);
		return weekList;
	}

	/**
	 * 订单状态下拉框
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/orderStatusList")
	public Object orderStatusList(@RequestBody AbstractBo bo) throws DzcxException {
		return EnumUtil.listSelect(订单状态显示2.class);
	}

	/**
	 * 订单类型下拉框
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@PostMapping("/orderTypeList")
	public Object orderTypeList(@RequestBody AbstractBo bo) throws DzcxException {
		return EnumUtil.listSelect(ProductType.class);
	}

	/**
	 * 菜单图标
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/iconList")
	public Object iconList(DetailIconBo bo) throws DzcxException {
		String[] iconStrList  = Icon.getMap().get(bo.getSystem()).split(",");
		List<String> iconList = new ArrayList<>();
		for (String icon : iconStrList) {
			iconList.add(icon);
		}
		return iconStrList;
	}

	/**
	 * 车辆类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/carTypeList")
	public Object carTypeList() throws DzcxException {
		return EnumUtil.listSelect(车辆类型.class);
	}

	/**
	 * 乘车类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/rideTypeList")
	public Object rideTypeList() throws DzcxException {
		return EnumUtil.listSelect(RideType.class);
	}

	/**
	 * 出行目的
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/travelPurpose")
	public Object travelPurposeList() throws DzcxException {
		return EnumUtil.listSelect(TravelPurpose.class);
	}

	/**
	 * 站点类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/siteType")
	public Object siteTypeList() throws DzcxException {
		return EnumUtil.listSelect(SiteType.class);
	}

	/**
	 * 上下车类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/takeTypeList")
	public Object takeTypeList() throws DzcxException {
		return EnumUtil.listSelect(TakeType.class);
	}

	/**
	 * 策略类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/strategyTypeList")
	public Object strategyTypeList() throws DzcxException {
		return EnumUtil.listSelect(StrategyType.class);
	}

	/**
	 * 运营状态
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/operationStatusList")
	public Object operationStatusList() throws DzcxException {
		return EnumUtil.listSelect(OperationStatus.class);
	}

	/**
	 * 售卖-售停
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/canSellList")
	public Object canSellList() throws DzcxException {
		return EnumUtil.listSelect(CanSellType.class);
	}

	/**
	 * 公告类型
	 * @return
	 * @throws DzcxException
	 */
	@ResponseBody
	@RequestMapping("/noticeType")
	public Object noticeTyleList() throws DzcxException {
		return EnumUtil.listSelect(NoticeType.class);
	}



}
